<?php

namespace App\JsonRpc;

use Hyperf\RpcServer\Annotation\RpcService;

/**
 * 注意，如希望通过服务中心来管理服务，需在注解内增加 publishTo 属性
 */
#[RpcService(name: 'CalculatorService', server: 'jsonrpc-http', protocol: 'jsonrpc-http',publishTo: 'nacos')]
class CalculatorService implements CalculatorServiceInterface
{
    public function sum(float $a, float $b): array
    {
        // TODO: Implement sum() method.
        return [
            'service' => 'UserService',
            'result' => $a + $b
        ];
    }

    public function sumPro(float $a, float $b): array
    {
        // TODO: Implement sumPro() method.
        return [
            'service' => 'UserService',
            'result' => ($a + $b) * 2
        ];
    }
}
